Skip to content

Add postcondition: declarative expected-outcome specs for actions#381

Merged
JE-Chen merged 1 commit into
devfrom
feat/postcondition-batch
Jun 23, 2026
Merged

Add postcondition: declarative expected-outcome specs for actions#381
JE-Chen merged 1 commit into
devfrom
feat/postcondition-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 23, 2026

Copy link
Copy Markdown
Member

摘要

新增 check_postcondition / compile_postcondition — 以小型 JSON 規格斷言動作的預期畫面結果,對照 before 幀做差異。expect_poll / assert_eventually 輪詢單一條件,沒有與動作綁定的後置條件規格,也不對照 before 基準(因此無法表達「一個對話框出現了」);trajectory_eval 是整條軌跡層級。

本功能對 after 觀測(可選擇與 before 觀測做差異)評估子句規格——appears / disappears(對照 before)、enabled / disabledtext_present / text_absentcount(equals / min)——回傳逐子句的通過 / 失敗報告。appears 只有在元素於 after 出現且在 before(確為新元素)時才成功。compile_postcondition 把規格轉成 after -> bool 判定函式以供 expect_poll 搭配。純標準函式庫;規格為純 JSON 可帶入 action 檔 / MCP / 排程器。Qt-free。

五層

  • 核心:utils/postcondition/PostconditionReportcheck_postconditioncompile_postcondition
  • Facade:由 je_auto_control 匯出 + __all__
  • Executor:AC_check_postcondition({ok, clauses, failed})。
  • MCP:ac_check_postcondition(read-only)。
  • Script Builder:Check Postcondition(Native UI)。
  • 文件:v169 EN + Zh + toctree。更新日誌:root EN + zh-TW + zh-CN。

測試

test/unit_test/headless/test_postcondition_batch.py — 新對話框出現(對照 before)、已存在則 appears 失敗、disabled+text_present、count equals/min、disappears 需 before、未知子句乾淨失敗、compile 判定函式、wiring + facade。9 passed。ruff / bandit / radon / float-scan / Qt-free 全乾淨。

expect_poll/assert_eventually poll a single condition with no action-bound spec
and no before-baseline, so they can't express 'a new dialog appeared';
trajectory_eval is whole-trajectory. Evaluate a small JSON spec of clauses
(appears/disappears/enabled/disabled/text_present/text_absent/count) against
the after-observation, diffed against the before-observation, returning a
per-clause pass/fail report. compile_postcondition yields an after->bool
predicate for expect_poll.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 60 complexity · 0 duplication

Metric Results
Complexity 60
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit d9b362c into dev Jun 23, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/postcondition-batch branch June 23, 2026 20:35
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant